/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.service;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.sys.dao.TbUserVerifyDao;
import com.thinkgem.jeesite.modules.sys.entity.TbUserVerify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 身份证审核Service
 * @author huoyan403
 * @version 2016-10-29
 */
@Service
@Transactional(readOnly = true)
public class TbUserVerifyService extends CrudService<TbUserVerifyDao, TbUserVerify> {
	@Autowired
	private TbUserVerifyDao userVerifyDao;
	public TbUserVerify get(String id) {
		return super.get(id);
	}
	
	public List<TbUserVerify> findList(TbUserVerify tbUserVerify) {
		return super.findList(tbUserVerify);
	}
	
	public Page<TbUserVerify> findPage(Page<TbUserVerify> page, TbUserVerify tbUserVerify) {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		try{
			if(tbUserVerify.getEndDate()!=null&&!"".equals(tbUserVerify.getEndDate())){
				Date date=sdf.parse(tbUserVerify.getEndDate());
				if(date!=null){
					date.setHours(23);
					date.setMinutes(59);
					date.setSeconds(59);
				}
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return super.findPage(page, tbUserVerify);
	}
	public Page<TbUserVerify> findListAgent(Page<TbUserVerify> page, TbUserVerify tbUserVerify) {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		try{
			if(tbUserVerify.getEndDate()!=null&&!"".equals(tbUserVerify.getEndDate())){
				Date date=sdf.parse(tbUserVerify.getEndDate());
				if(date!=null){
					date.setHours(23);
					date.setMinutes(59);
					date.setSeconds(59);
				}
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return super.findPage(page, tbUserVerify);
	}

	@Transactional(readOnly = false)
	public void save(TbUserVerify tbUserVerify) {
		super.save(tbUserVerify);
	}
	@Transactional(readOnly = false)
		public void edit(TbUserVerify tbUserVerify) {
			userVerifyDao.update(tbUserVerify);
		}

	@Transactional(readOnly = false)
	public void delete(TbUserVerify tbUserVerify) {
		super.delete(tbUserVerify);
	}

	public TbUserVerify getVerifyById(String uid) {
		Integer id=Integer.parseInt(uid);
		return userVerifyDao.getByUid(id);
	}
	
}